package com.hzdaba.aiapi.controllerAdvice;

import com.hzdaba.aiapi.vo.AiApiResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常处理类
 *
 * @author 刘逸晖
 */
@ControllerAdvice
public class GlobalExceptionControllerAdvice {

    /**
     * 处理所有异常
     *
     * @param exception 异常
     * @return 错误响应
     */
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public AiApiResponse handleException(Exception exception) {
        return AiApiResponse.fail("服务器繁忙，请稍后再试");
    }

}
